package com.ruoyi.airsystem.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.airsystem.domain.AirWarnings;
import com.ruoyi.airsystem.service.IAirWarningsService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 警告管理Controller
 *
 * @date 2025-04-18
 */
@RestController
@RequestMapping("/airsystem/warnings")
public class AirWarningsController extends BaseController
{
    @Autowired
    private IAirWarningsService airWarningsService;

    /**
     * 查询警告管理列表
     */
    @PreAuthorize("@ss.hasPermi('airsystem:warnings:list')")
    @GetMapping("/list")
    public TableDataInfo list(AirWarnings airWarnings)
    {
        startPage();
        List<AirWarnings> list = airWarningsService.selectAirWarningsList(airWarnings);
        return getDataTable(list);
    }

    /**
     * 导出警告管理列表
     */
    @PreAuthorize("@ss.hasPermi('airsystem:warnings:export')")
    @Log(title = "警告管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AirWarnings airWarnings)
    {
        List<AirWarnings> list = airWarningsService.selectAirWarningsList(airWarnings);
        ExcelUtil<AirWarnings> util = new ExcelUtil<AirWarnings>(AirWarnings.class);
        util.exportExcel(response, list, "警告管理数据");
    }

    /**
     * 获取警告管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('airsystem:warnings:query')")
    @GetMapping(value = "/{warningId}")
    public AjaxResult getInfo(@PathVariable("warningId") Long warningId)
    {
        return success(airWarningsService.selectAirWarningsByWarningId(warningId));
    }

    /**
     * 新增警告管理
     */
    @PreAuthorize("@ss.hasPermi('airsystem:warnings:add')")
    @Log(title = "警告管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AirWarnings airWarnings)
    {
        return toAjax(airWarningsService.insertAirWarnings(airWarnings));
    }

    /**
     * 修改警告管理
     */
    @PreAuthorize("@ss.hasPermi('airsystem:warnings:edit')")
    @Log(title = "警告管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AirWarnings airWarnings)
    {
        return toAjax(airWarningsService.updateAirWarnings(airWarnings));
    }

    /**
     * 删除警告管理
     */
    @PreAuthorize("@ss.hasPermi('airsystem:warnings:remove')")
    @Log(title = "警告管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{warningIds}")
    public AjaxResult remove(@PathVariable Long[] warningIds)
    {
        return toAjax(airWarningsService.deleteAirWarningsByWarningIds(warningIds));
    }
}
